package net.lab1024.sa.admin.module.business.erp.mmo.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import net.lab1024.sa.admin.module.business.erp.mmo.domain.entity.MmordbEntity;
import net.lab1024.sa.admin.module.business.erp.mmo.domain.form.MmordbAddForm;
import net.lab1024.sa.admin.module.business.erp.mmo.domain.form.MmordbQueryForm;
import net.lab1024.sa.admin.module.business.erp.mmo.domain.form.MmordbUpdateForm;
import net.lab1024.sa.admin.module.business.erp.mmo.domain.vo.MmordbVO;
import net.lab1024.sa.admin.module.business.erp.mmo.service.MmordbService;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 生产订单与用户关系表 Controller
 *
 * @Author AKITA
 * @Date 2025-04-19 12:52:24
 * @Copyright AKITA
 */

@RestController
@Tag(name = "生产订单与用户关系表")
public class MmordbController {

    @Resource
    private MmordbService mmordbService;

    @Operation(summary = "分页查询 @author AKITA")
    @PostMapping("/mmordb/queryPage")
    public ResponseDTO<PageResult<MmordbVO>> queryPage(@RequestBody @Valid MmordbQueryForm queryForm) {
        return ResponseDTO.ok(mmordbService.queryPage(queryForm));
    }


    @PostMapping("/mmordb/list")
    public ResponseDTO<List<MmordbEntity>> list(@RequestBody MmordbQueryForm queryForm) {
        return ResponseDTO.ok(mmordbService.list(queryForm));
    }

    @Operation(summary = "添加 @author AKITA")
    @PostMapping("/mmordb/add")
    public ResponseDTO<String> add(@RequestBody @Valid MmordbAddForm addForm) {
        return mmordbService.add(addForm);
    }

    @Operation(summary = "更新 @author AKITA")
    @PostMapping("/mmordb/update")
    public ResponseDTO<String> update(@RequestBody @Valid MmordbUpdateForm updateForm) {
        return mmordbService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author AKITA")
    @PostMapping("/mmordb/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return mmordbService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author AKITA")
    @GetMapping("/mmordb/delete/{docEntry}")
    public ResponseDTO<String> batchDelete(@PathVariable Long docEntry) {
        return mmordbService.delete(docEntry);
    }

    @PostMapping("/mmordb/deleteLine")
    public ResponseDTO<String> deleteLine(@RequestBody MmordbQueryForm queryForm) {
        return mmordbService.deleteLine(queryForm);
    }


}
